<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h2>ES5继承</h2>
</body>
<script>
    //A和B类，B如何继承A?
    function Person(name='无名',age=0) {
        this.name=name;
        this.age=age;
    }

    Person.prototype.play=function() {
        console.log(`${this.name}爱打游戏`)
    }

    // const p1=new Person('张三')
    // p1.play()

    function Chinese(name='子类无名') {
        Person.call(this,name) 
    }

    //原型链继承
   Chinese.prototype=new Person();

    const c1=new Chinese('hello');
    c1.play()

</script>
</html>